/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package sk.smitala.gephi.communitydetection.scan;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.net.URI;
import java.net.URISyntaxException;
import javax.swing.SwingConstants;
import org.openide.util.Exceptions;
import sk.smitala.gephi.communitydetection.utils.CommonUtils;

/**
 *
 * @author smitalm
 */
public class ScanClustererPanel extends javax.swing.JPanel {

    /**
     * Creates new form ScanClustererPanel
     */
    public ScanClustererPanel() {
	initComponents();
	setLinkButton();
    }

    public boolean getGroupHubs() {
	return groupHubs.isSelected();
    }

    public void setGroupHubs(boolean b) {
	groupHubs.setSelected(b);
    }

    public boolean getGroupOutliers() {
	return groupOutliers.isSelected();
    }

    public void setGroupOutliers(boolean b) {
	groupOutliers.setSelected(b);
    }

    public boolean getExperimentalImprovement() {
	return experimentalImprovement.isSelected();
    }

    public void setExperimentalImprovement(boolean b) {
	experimentalImprovement.setSelected(b);
    }

    private void setLinkButton() {
	final URI uri;
	try {
	    uri = new URI("http://www.ualr.edu/nxyuruk/publications/kdd07.pdf");
	} catch (URISyntaxException ex) {
	    Exceptions.printStackTrace(ex);
	    linkButton.setEnabled(false);
	    return;
	}
	linkButton.setToolTipText(uri.toString());
	linkButton.addMouseListener(new MouseListener() {
	    @Override
	    public void mouseClicked(MouseEvent e) {
		CommonUtils.open(uri);
	    }

	    @Override
	    public void mousePressed(MouseEvent e) {
	    }

	    @Override
	    public void mouseReleased(MouseEvent e) {
	    }

	    @Override
	    public void mouseEntered(MouseEvent e) {
	    }

	    @Override
	    public void mouseExited(MouseEvent e) {
	    }
	});
    }

    @Override
    public Dimension getPreferredSize() {
	return new Dimension(700, 433);
    }

    /**
     * Add here setters and getters for all properties users can edit.
     */
    public void setEpsilon(double epsilon) {
	this.epsilon.setText(epsilon + "");
    }

    public double getEpsilon() {
	try {
	    return Double.parseDouble(this.epsilon.getText());
	} catch (NumberFormatException e) {
	    e.printStackTrace(System.err);
	    return ScanClusterer.EPSILON_DEFAULT;
	}
    }

    public void setMu(int mu) {
	this.mu.setText(mu + "");
    }

    public int getMu() {
	try {
	    return Integer.parseInt(this.mu.getText());
	} catch (NumberFormatException e) {
	    e.printStackTrace(System.err);
	    return ScanClusterer.MU_DEFAULT;
	}
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        epsilonLabel = new javax.swing.JLabel();
        muLabel = new javax.swing.JLabel();
        epsilon = new javax.swing.JTextField();
        mu = new javax.swing.JTextField();
        epsilonDescription = new javax.swing.JLabel();
        muDescription = new javax.swing.JLabel();
        algorithmParams = new javax.swing.JLabel();
        header = new org.jdesktop.swingx.JXHeader();
        linkButton = new javax.swing.JLabel();
        algorithmParams1 = new javax.swing.JLabel();
        groupHubs = new javax.swing.JCheckBox();
        epsilonDescription1 = new javax.swing.JLabel();
        groupOutliers = new javax.swing.JCheckBox();
        epsilonDescription2 = new javax.swing.JLabel();
        algorithmParams2 = new javax.swing.JLabel();
        experimentalImprovement = new javax.swing.JCheckBox();

        setMaximumSize(new java.awt.Dimension(706, 274));

        epsilonLabel.setFont(new java.awt.Font("Tahoma", 2, 11)); // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(epsilonLabel, org.openide.util.NbBundle.getMessage(ScanClustererPanel.class, "ScanClustererPanel.epsilonLabel.text")); // NOI18N

        muLabel.setFont(new java.awt.Font("Tahoma", 2, 11)); // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(muLabel, org.openide.util.NbBundle.getMessage(ScanClustererPanel.class, "ScanClustererPanel.muLabel.text")); // NOI18N

        epsilon.setText(org.openide.util.NbBundle.getMessage(ScanClustererPanel.class, "ScanClustererPanel.epsilon.text")); // NOI18N

        mu.setText(org.openide.util.NbBundle.getMessage(ScanClustererPanel.class, "ScanClustererPanel.mu.text")); // NOI18N

        org.openide.awt.Mnemonics.setLocalizedText(epsilonDescription, org.openide.util.NbBundle.getMessage(ScanClustererPanel.class, "ScanClustererPanel.epsilonDescription.text")); // NOI18N

        org.openide.awt.Mnemonics.setLocalizedText(muDescription, org.openide.util.NbBundle.getMessage(ScanClustererPanel.class, "ScanClustererPanel.muDescription.text")); // NOI18N

        algorithmParams.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(algorithmParams, org.openide.util.NbBundle.getMessage(ScanClustererPanel.class, "ScanClustererPanel.algorithmParams.text")); // NOI18N

        header.setDescription(org.openide.util.NbBundle.getMessage(ScanClustererPanel.class, "ScanClustererPanel.header.description")); // NOI18N
        header.setTitle(org.openide.util.NbBundle.getMessage(ScanClustererPanel.class, "ScanClustererPanel.header.title")); // NOI18N

        org.openide.awt.Mnemonics.setLocalizedText(linkButton, org.openide.util.NbBundle.getMessage(ScanClustererPanel.class, "ScanClustererPanel.linkButton.text")); // NOI18N
        linkButton.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));

        algorithmParams1.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(algorithmParams1, org.openide.util.NbBundle.getMessage(ScanClustererPanel.class, "ScanClustererPanel.algorithmParams1.text")); // NOI18N

        org.openide.awt.Mnemonics.setLocalizedText(groupHubs, org.openide.util.NbBundle.getMessage(ScanClustererPanel.class, "ScanClustererPanel.groupHubs.text")); // NOI18N

        org.openide.awt.Mnemonics.setLocalizedText(epsilonDescription1, org.openide.util.NbBundle.getMessage(ScanClustererPanel.class, "ScanClustererPanel.epsilonDescription1.text")); // NOI18N

        org.openide.awt.Mnemonics.setLocalizedText(groupOutliers, org.openide.util.NbBundle.getMessage(ScanClustererPanel.class, "ScanClustererPanel.groupOutliers.text")); // NOI18N

        org.openide.awt.Mnemonics.setLocalizedText(epsilonDescription2, org.openide.util.NbBundle.getMessage(ScanClustererPanel.class, "ScanClustererPanel.epsilonDescription2.text")); // NOI18N

        algorithmParams2.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(algorithmParams2, org.openide.util.NbBundle.getMessage(ScanClustererPanel.class, "ScanClustererPanel.algorithmParams2.text")); // NOI18N

        org.openide.awt.Mnemonics.setLocalizedText(experimentalImprovement, org.openide.util.NbBundle.getMessage(ScanClustererPanel.class, "ScanClustererPanel.experimentalImprovement.text")); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(header, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 8, Short.MAX_VALUE))
            .addGroup(layout.createSequentialGroup()
                .addGap(27, 27, 27)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(experimentalImprovement)
                    .addComponent(algorithmParams2, javax.swing.GroupLayout.PREFERRED_SIZE, 368, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(algorithmParams1, javax.swing.GroupLayout.PREFERRED_SIZE, 368, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(linkButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(muLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(epsilonLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(mu, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(muDescription))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(epsilon, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(epsilonDescription))))
                    .addComponent(algorithmParams, javax.swing.GroupLayout.PREFERRED_SIZE, 368, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(groupOutliers)
                            .addComponent(groupHubs))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(epsilonDescription1)
                            .addComponent(epsilonDescription2))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(header, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(linkButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(algorithmParams)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(epsilonLabel)
                    .addComponent(epsilon, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(epsilonDescription))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(muLabel)
                    .addComponent(mu, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(muDescription))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(algorithmParams1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(groupHubs)
                    .addComponent(epsilonDescription1))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(groupOutliers)
                    .addComponent(epsilonDescription2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(algorithmParams2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(experimentalImprovement)
                .addContainerGap(15, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel algorithmParams;
    private javax.swing.JLabel algorithmParams1;
    private javax.swing.JLabel algorithmParams2;
    private javax.swing.JTextField epsilon;
    private javax.swing.JLabel epsilonDescription;
    private javax.swing.JLabel epsilonDescription1;
    private javax.swing.JLabel epsilonDescription2;
    private javax.swing.JLabel epsilonLabel;
    private javax.swing.JCheckBox experimentalImprovement;
    private javax.swing.JCheckBox groupHubs;
    private javax.swing.JCheckBox groupOutliers;
    private org.jdesktop.swingx.JXHeader header;
    private javax.swing.JLabel linkButton;
    private javax.swing.JTextField mu;
    private javax.swing.JLabel muDescription;
    private javax.swing.JLabel muLabel;
    // End of variables declaration//GEN-END:variables
}
